﻿<Window x:Class="MineSweeper.Windows.ChangeAppearance"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:data="clr-namespace:MineSweeper.Data"
        xmlns:commands="clr-namespace:MineSweeper.Commands"
        xmlns:valueConverters="clr-namespace:SwiftMVVM.ValueConverters;assembly=SwiftMVVM"
        Title="Change Appearance" Height="450" Width="500" 
        WindowStartupLocation="CenterScreen"
        Name="chooseAppearanceWindow"
        Style="{StaticResource optionWindowBackgroundStyle}">
    <Window.Resources>
        <valueConverters:MultiValueConverter x:Key="MultiValueConverter"/>
    </Window.Resources>
    <Window.DataContext>
        <ObjectDataProvider ObjectType="{x:Type data:GameOptions}" MethodName="Create"/>
    </Window.DataContext>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.Resources>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Margin" Value="8,4,8,4"/>
                </Style>
                <Style TargetType="TextBlock">
                    <Setter Property="Margin" Value="5"/>
                    <Setter Property="HorizontalAlignment" Value="Center"/>
                </Style>
                <Style TargetType="CheckBox">
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style TargetType="ListBox">
                    <Setter Property="Margin" Value="5,0,5,0"/>
                    <Setter Property="ItemsPanel">
                        <Setter.Value>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <TextBlock Text="Select game and style"/>
            <ListBox Grid.Row="1" SelectionChanged="IconList_SelectionChanged">
                <ListBox.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                    </Style>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="8,4,8,34"/>
                    </Style>
                    <Style TargetType="Image">
                        <Setter Property="Width" Value="72"/>
                    </Style>
                </ListBox.Resources>
                <ListBoxItem Name="mineSweeper">
                    <StackPanel>
                        <Image Source="/MineSweeper;component/Resources/mine.png" />
                        <TextBlock Text="Minesweeper"/>
                    </StackPanel>
                </ListBoxItem>
                <ListBoxItem Name="flowerGarden">
                    <StackPanel>
                        <Image Source="/MineSweeper;component/Resources/flowergarden_gamethumb.png" />
                        <TextBlock Text="Flower Garden"/>
                    </StackPanel>
                </ListBoxItem>
            </ListBox>
            <TextBlock Grid.Row="2" Text="Select Board"/>
            <ListBox Grid.Row="3" SelectionChanged="BoardList_SelectionChanged">
                <ListBoxItem Name="BlueTilesMinesweeper">
                    <StackPanel>
                        <Image Source="/MineSweeper;component/Resources/blueBoard.png" />
                        <TextBlock Text="Silver and Blue"/>
                    </StackPanel>
                </ListBoxItem>
                <ListBoxItem Name="GreenTilesMinesweeper">
                    <StackPanel>
                        <Image Source="/MineSweeper;component/Resources/greenBoard.png" />
                        <TextBlock Text="Green"/>
                    </StackPanel>
                </ListBoxItem>
            </ListBox>
            <CheckBox IsChecked="{Binding RandomGameStyleAndBoard}" Grid.Row="4" Content="Randomly choose game style and board"/>
        </Grid>
        <Grid Grid.Row="1" Margin="5">
            <Grid.Resources>
                <Style TargetType="Button">
                    <Setter Property="MinWidth" Value="100" />
                    <Setter Property="Margin" Value="5" />
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="1" Content="Ok" IsDefault="True" 
                    Command="{x:Static commands:GameCommands.SaveAppearanceAndCloseWindow}">
                <Button.CommandParameter>
                    <MultiBinding Converter="{StaticResource MultiValueConverter}">
                        <MultiBinding.Bindings>
                            <Binding ElementName="chooseAppearanceWindow"/>
                            <Binding />
                        </MultiBinding.Bindings>
                    </MultiBinding>
                </Button.CommandParameter>
            </Button>
            <Button Grid.Column="2" Content="Cancel" IsCancel="True"/>
        </Grid>
    </Grid>
</Window>
